﻿using CuoiHoi.Business;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CuoiHoi.UserControls
{
    public partial class ChiTietMedia : System.Web.UI.UserControl
    {
        public DataTable TbAnh;
        protected void Page_Load(object sender, EventArgs e)
        {
            int IdAlbum = int.Parse(Page.RouteData.Values["IdItemMedia"].ToString());
            string Title = Page.RouteData.Values["TitleMedia"].ToString();
            TbAnh = BAlbum.SelectByID(IdAlbum);

            if (TbAnh.Rows.Count > 0)
            {
                if (Router.NonUnicode(TbAnh.Rows[0]["TenAlbum"].ToString()) != Title)
                    Response.RedirectToRoute("ChiTietMedia",
                        new
                        {
                            TitleMedia = Router.NonUnicode(TbAnh.Rows[0]["TenAlbum"].ToString()),
                              IdMedia = TbAnh.Rows[0]["idTheLoai"].ToString(),
                              IdItemMedia = TbAnh.Rows[0]["IdAlbum"].ToString()
                        });
            }
            else
                Response.RedirectToRoute("Error");
        }
    }
}